import { observable, action, autorun, toJS, computed } from 'mobx';
import * as  Apis from '../../apis/mindmap';
import { TaskInfoStore } from '../task/taskInfoStore'
import { TaskCardStore } from "./taskCardStore";
import { PrjCardStore } from "../projectBoard/prjCardStore";
export class MindMapStore {

    @observable nodeTreeData = {};

    @observable scale = 1;

    @observable _key = 1;

	@action	changeScale = (scale) => {
		this.scale = scale;
	}

    @observable taskInfoStore = new TaskInfoStore();
    
    @observable prjTaskCardStore = new TaskCardStore();

    @observable prjCardStore = new PrjCardStore();

    @observable showRight = false;

    @observable renderType = "";

    @observable selectObj = {};

    @observable prjid = "";

    @action
    initPath = (params, readonly) => {
        this.prjid = params.prjid;
        this.readonly = readonly;
        Apis.getPrjMindMap(params).then((data)=>{
            this.nodeTreeData.versionNode = data.data;
            this._key++;
        });
    }

    @action
    showSlideModal = (bool) => {
        this.showRight = bool;
    }

    @action
    setRenderType = (type) => {
        this.renderType = type;
    }

    @action
    selectNodeObj = (obj) => {
        this.selectObj = obj;
    }

    @action
    refresh = () => {
        this.initPath({prjid:this.prjid});
    }

}

export default new MindMapStore